package com.hyl.domain.tag.service;

import com.hyl.domain.tag.adapter.repository.ITagRepository;
import com.hyl.domain.tag.model.entity.CrowdTagsJobEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author hyl
 * @description tag标签的接口的实现
 * @create 2025-06-18 15:09
 */
@Slf4j
@Service
public class TagService implements ITagService{

    @Resource
    private ITagRepository repository;
    @Override
    public void execTagBatchJob(String tagId, String batchId) {
        log.info("开始执行人群标签标签批次任务，tagId: {}, batchId: {}", tagId, batchId);
        // 1. 查询标签批次信息
        CrowdTagsJobEntity crowdTagsJobEntity = repository.queryCrowdTagsJobEntity(tagId, batchId);

        //2.采集用户数据需要统计消费人群的标签，后续有用户发起拼单后再处理

        //3.数据写入记录
        List<String> userIdList = new ArrayList<String>() {{
            add("xiaofuge");
            add("zxw");
        }};

        //4.
        for(String userId : userIdList){
            repository.addCrowdTagsUserId(tagId, userId);
        }


        //5，更新人群标签统计量
        repository.updateCrowdTagsStatistics(tagId,userIdList.size());


    }
}
